<?php
/*
 * Create Lastest games widget
* */
class Tuvan extends WP_Widget
{
	function Tuvan()
	{
		parent::WP_Widget('Tuvan',
				__("Thông tin tư vấn"),
				array('description' => __("Thả vào sidebar hiển thị thông tin tư vấn",THEMENAME)));

	}

	function widget( $args, $instance ) // hien thi noi dung widget
	{
		extract($args);
		$title = apply_filters( 'widget_title',
				empty($instance['title']) ? '' : $instance['title'],
				$instance, $this->id_base);
				
		$avatar = apply_filters( 'widget_text',
				$instance['avatar'], $instance );
		
		$name = apply_filters( 'widget_text',
				$instance['name'], $instance );
		$hotline = apply_filters( 'widget_text',
				$instance['hotline'], $instance );
	
		?>
		<div class="module">
			<div>
				<div>
					<div>
						<h3 style="line-height: 45px;">THÔNG TIN TƯ VẤN</h3>
						 <div id="content" >
							<span style="font-size: small;">							
							<p style="text-align: center;">
								<?php if($avatar){?>
								<img style="max-width: 200px; max-height: 193px;" src="<?php echo $avatar;?>" border="0" alt="Admin site infocanho.com" title="Admin site infocanho.com" />
								<?php 
								}
								else 
								{
								?>								
								<img width="96" height="96" class="avatar avatar-96 photo" src="http://0.gravatar.com/avatar/424e381a401a61dc5793e57ebaf55aa5?s=96&amp;d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&amp;r=G" alt="">								
								<?php 		
								}
								?>
							</p>
							<span style="color: #003300;">
								<div style="text-align: center;">
									<strong><span style="font-size: medium;"><br /><?php echo $name;?></span></strong></div>
								<span style="color: #800000;"><span style="font-size: large;"> </span>
								<div style="text-align: center;"><strong>
									<span style="font-size: large;"> Hotline: <?php echo $hotline;?></span></strong></div>
								</span>
							</span>
							</span>                    
						</div>
					</div>
				</div>
			</div>
		</div>
		<?php 
		
	}

	function update( $new_instance, $old_instance ) 
	{
		$instance = $old_instance;
				
		$instance['title'] = strip_tags($new_instance['title']);
		$instance['avatar'] = strip_tags($new_instance['avatar']);
		$instance['name'] = strip_tags($new_instance['name']);
		$instance['hotline'] = strip_tags($new_instance['hotline']);
		return $instance;
	}

	function form( $instance ) 
	{
		$instance = wp_parse_args( (array) $instance, 
			array( 'title' => '','showposts' => '','showthumb' => ''));
		$title = strip_tags($instance['title']);
		$avatar = strip_tags($instance['avatar']);
		$name = strip_tags($instance['name']);
		$hotline = strip_tags($instance['hotline']);
				
	?>
			<p>
				<label for="<?php echo $this->get_field_id('title'); ?>">
					<?php echo  __('Tiêu đề:',THEMENAME); ?> </label>
				<input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" 
					name="<?php echo $this->get_field_name('title'); ?>" type="text" 
					value="<?php if($title) echo  esc_attr($title);?>" />
			</p>
			<p>
				<label for="<?php echo $this->get_field_id('avatar'); ?>">
					<?php echo  __('Link hình Avatar',THEMENAME); ?> </label>
				<input class="widefat" id="<?php echo $this->get_field_id('avatar'); ?>" 
					name="<?php echo $this->get_field_name('avatar'); ?>" type="text" 
					value="<?php if($avatar) echo  esc_attr($avatar);?>" />
			</p>
			<p>
				<label for="<?php echo $this->get_field_id('name'); ?>">
					<?php echo  __('Người tư vấn',THEMENAME); ?> </label>
				<input class="widefat" id="<?php echo $this->get_field_id('name'); ?>" 
					name="<?php echo $this->get_field_name('name'); ?>" type="text" 
					value="<?php if($name) echo  esc_attr($name);?>" />	
				
			</p>	
			<p>
				<label for="<?php echo $this->get_field_id('hotline'); ?>">
					<?php echo  __('Hotline',THEMENAME); ?> </label>
				<input class="widefat" id="<?php echo $this->get_field_id('hotline'); ?>" 
					name="<?php echo $this->get_field_name('hotline'); ?>" type="text" 
					value="<?php if($hotline) echo  esc_attr($hotline);?>" />	
				
			</p>						
	<?php
	}
}
// Register Widgets
register_widget('Tuvan');
// End Widget Tuvan
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++